﻿<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>绘制图片-连续动</title>
<style>
body {text-align:center; background:black;}
#c1 {background:white;}
</style>
<script>
window.onload=function ()
{
	var oC=document.getElementById('c1');
	var gd=oC.getContext('2d');
	
	var oImg=new Image();
	var i=0;
	var t=600;
	
	oImg.onload=function ()
	{
		setInterval(function (){
			t-=10;
			
			gd.clearRect(0, 0, oC.width, oC.height);
			gd.drawImage(oImg, 32*i, 0, 32, 32, 200, t, 128, 128);
			
			i++;
			
			if(i==2)
			{
				i=0;
			}
		}, 150);
	};
	oImg.src='sheet_characters.png';
};
</script>
</head>

<body>
<canvas id="c1" width="800" height="600"></canvas>
</body>
</html>
